{include file="common/login_header"/}
<div class="uwlogin">
  <div class="uwbanner">
    <div class="swiper-wrapper">
      <div class="swiper-slide" style="background: url(__STATIC__/lib/index/images_new/qms4.jpg) no-repeat center/cover;">
        <div class="txt">
          <h4>&nbsp;</h4>
          <h5>&nbsp;</h5>
        </div>
      </div>
      <div class="swiper-slide" style="background: url(__STATIC__/lib/index/images_new/qms4.jpg) no-repeat center/cover;">
        <div class="txt">
          <h4>&nbsp;</h4>
          <h5>&nbsp;</h5>
        </div>
      </div>
      <div class="swiper-slide" style="background: url(__STATIC__/lib/index/images_new/qms4.jpg) no-repeat center/cover;">
        <div class="txt">
          <h4>&nbsp;</h4>
          <h5>&nbsp;</h5>
        </div>
      </div>
    </div>
    <div class="spot"></div>
  </div>
  <div class="uwform">
    <form action="" method="post">
      <div class="tps">
        <a href="#" class="logo" style="font-weight: bold;font-size: 25px;color: #00aeef">CardEcho</a>
<!--        <dl>-->
<!--          <dd class="on"><a href="#">中</a></dd>-->
<!--          <dd><a href="#">EN</a></dd>-->
<!--        </dl>-->
      </div>
      <h2>登录您的账户</h2>
      <div class="navs">
        <ul>
          <li class="on" id="user_action"><a href='javascript:;'>账号登录</a></li>
          <li id="email_action"><a href='javascript:;' >邮箱快捷登录</a></li>
        </ul>
      </div>
      <div class="box">
        <div class="fms" id="user_action_form">
          <ul>
            <li>
              <div class="ico">
                <img src="__STATIC__/lib/index/images_new/qms5.png" alt="">
              </div>
              <input class="t1" type="text"  name="username" id="username" placeholder="请输入邮箱">
            </li>
            <li>
              <div class="ico">
                <img src="__STATIC__/lib/index/images_new/qms2.png" alt="">
              </div>
              <input class="t1" type="password" value="" name="password" id="password" placeholder="请输入密码">
            </li>
          </ul>
          <a href="javascript:;" class="btn" id="check_sub">登 录</a>
        </div>
        <div class="fms" id="email_action_form">
          <ul>
            <li>
              <div class="ico">
                <img src="__STATIC__/lib/index/images_new/qm8.png" alt="">
              </div>
              <input class="t1" type="text" value="" name="email" id="email" placeholder="请输入邮箱">
            </li>
            <li>
              <div class="ico">
                <img src="__STATIC__/lib/index/images_new/qms6.png" alt="">
              </div>
              <div class="rs">
                <input class="t1 t2" type="text" value="" name="vercode" id="vercode" placeholder="请输入验证码">
                <h6 id="getsmscode" style="cursor:pointer">获取验证码</h6>
              </div>
            </li>
          </ul>
          <a href="javascript:;" class="btn" id="check_email">提 交</a>
        </div>
      </div>
      <div class="flax">
        <div class="che">
          {if $open_close_reg != 1}
          <dl>
            <dd>
              <a href="{:url('signIn')}" class="h7">立即注册</a>
            </dd>
          </dl>
          {/if}
        </div>
        <a href="{:url('editPwd')}" class="h7">忘记密码？</a>
      </div>

      <br />

      <div class="flax">
        <div style="font-size: 15px;font-weight: bold">联系方式:<br /></div>
        <a href="javascript:;" style="font-size: 16px;" class="h8">邮箱:support@cardecho.com</a>
      </div>
    </form>
  </div>
</div>
{include file="common/login_footer"/}
<script type="text/javascript">
  layui.use('form', function() {
      var $ = layui.$,
        form = layui.form;

      //用户过期后，重定向全屏处理
      if (window != top) top.location.href = location.href;

      $(function(){
          if(browser.versions.mobile||browser.versions.android||browser.versions.ios){
             layer.msg('请使用PC端登录.', {time: 10000});
             return false;
          }
      });

      $('#vercode').val('');
      form.render();
      //提交
      $('#check_sub').click(function(){
          if(browser.versions.mobile||browser.versions.android||browser.versions.ios){
            layer.msg('请使用PC端登录.', {time: 10000});
            return false;
          }
          var loading = layer.load(1, {shade: [0.1, '#fff']});
          JsPost("{:url('login/checkLogin')}", {username:$('#username').val(),password:$("#password").val()}, function (data) {
              layer.close(loading);
              if (data.code == 0) {
                layer.msg('登录成功, 跳转中...', { time: 1500});
                setTimeout("window.location.href='" + data.data.href + "'; ", 1000);
              } else {
                if (data.code == '100010') {
                  $('.user_check').show();
                  $('#vercode').attr('lay-verify', 'required_en|number_en');
                  $('#vercode').attr('lay-verType', 'tips');
                } else if(data.code == '10'){
                  layer.msg(data.msg, {time: 1500});
                  $("#email_action").addClass('on');
                  $("#user_action").removeClass('on');
                  $('#user_action_form').hide();
                  $('#email_action_form').show();
                }else {
                  layer.msg(data.msg, {time: 1500});
                }
              }
          });
        return false;
      });

      $('#check_email').click(function(){
          if(browser.versions.mobile||browser.versions.android||browser.versions.ios){
            layer.msg('请使用PC端登录.', {time: 10000});
            return false;
          }
          var loading = layer.load(1, {shade: [0.1, '#fff']});
          JsPost("{:url('login/checkLoginEmail')}", {email:$('#email').val(),vercode:$("#vercode").val()}, function (data) {
              layer.close(loading);
              if (data.code == 0) {
                  layer.msg('登录成功, 跳转中...', { time: 1500});
                  setTimeout("window.location.href='" + data.data.href + "'; ", 1000);
              }else if(data.code == 2){
                  layer.msg(data.msg, {time: 1500});
                  setTimeout("window.location.href='" + "{:url('Index/signIn')}" + "'; ", 1000);
              } else{
                  if (data.code == '100010') {
                    $('.user_check').show();
                    $('#vercode').attr('lay-verify', 'required_en|number_en');
                    $('#vercode').attr('lay-verType', 'tips');
                  } else {
                    layer.msg(data.msg, {time: 1500});
                  }
              }
          });
          return false;
      })

    var browser={
      versions:function(){
        var u = navigator.userAgent,
                app = navigator.appVersion;
        return {
          trident: u.indexOf('Trident') > -1, //IE内核
          presto: u.indexOf('Presto') > -1, //opera内核
          webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
          gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
          mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
          ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
          android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
          iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
          iPad: u.indexOf('iPad') > -1, //是否iPad
          webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
          weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
          qq: u.match(/\sQQ/i) == " qq" //是否QQ
        };
      }(),
      language:(navigator.browserLanguage || navigator.language).toLowerCase()
    }

      var getCode = document.getElementById('getsmscode');
      var wait = 60;
      function time(btn){
          if (wait===0) {
            getCode.removeAttribute("disabled");
            getCode.innerHTML = "获取验证码";
            wait = 60;
          }else{
            getCode.setAttribute("disabled",true);
            getCode.innerHTML = "<font color='black'>" + wait + " </font> 秒";
            wait--;
            setTimeout(function(){
              time(btn);
            },1000);
          }
      }
      getCode.onclick = function(){
          const email = $("#email").val();
          if(!email){
            layer.msg('邮箱不能为空.',{icon: 16, time: 1500});
            $("#email").focus();
            return false;
          }
          const code = $("#getsmscode").text();
          if(code != '获取验证码'){
            layer.msg('正在发送中.',{icon: 16, time: 1500});
            return false;
          }
          $.post("{:url('login/emailSend')}", {username:email,send_type:'check_login'}, function (res) {
              if (res.code > 0) {
                time(this);
              } else {
                layer.msg(res.msg,{icon: 16, time: 1500});
              }
          });
      };
  });
  var swiper = new Swiper('.hmain .lt .textswip', {
    pagination: {
      el: '.span',
    },
    speed:800,
    loop: true, //循环
    autoplay: {
      delay: 3000,
      stopOnLastSlide: false, //如果设置为true，当切换到最后一个slide时停止自动切换。（loop模式下无效）。
      disableOnInteraction: false, //用户操作swiper之后，是否禁止autoplay。默认为true：停止。
    }
  });

  $('.hmain .rts .box .hs li').click(function() {
    $('.hmain .rts .box .hs li').removeClass('on');
    $(this).addClass('on');
    $('.hmain .rts .box .form').hide();
    $('.hmain .rts .box .form').eq($(this).index()).show();
  })
</script>

